package c17网络编程;

import java.io.IOException;
import java.net.InetAddress;
import java.net.UnknownHostException;

public class TestInetAddress {

	public static void main(String[] args) throws IOException {
		InetAddress ia;
//		ia = InetAddress.getLocalHost();
//		ia=InetAddress.getByName("www.baidu.com");
		//byte数组的长度为4！
		ia = InetAddress.getByAddress(new byte[]{127, 0, 0, 1});

		System.err.println(ia.isReachable(2000));
		//全局限定名
		System.err.println(ia.getCanonicalHostName());
		//IP地址
		System.err.println(ia.getHostAddress());
		//主机名
		System.err.println(ia.getHostName());
	}

}
